Why i cannot get the correct value of a checkbox inside a void function?

Hi everyone,
i use an DBE element which is called DBE default_view and i try to use this element inside of a void function where there is another void function. Inside this latter void function i use this element to create a checkbox which is successfully placed. The problem is when i check this box, i try to get its value by using get function which returns 0 whether the check box is checked or not. However whenever i use try to get its value in another void function which is place on top of all these void function that i mentioned, it prints me the correct value of the checkbox. i cannot see the reason why it does not function in these other void s. Furthermore i defined DBE default_view and the box on which it appears as global variables.

i do thank you in advance to those who pay attention.
SystemAdmin - Thu May 07 05:45:39 EDT 2009

Re: Why i cannot get the correct value of a checkbox inside a void function?
dpechacek - Thu May 07 08:32:09 EDT 2009

So to be clear it doesn't work in a void function inside a void function but it does work in another void function outside and above the first in the code?

If the DBE was out of scope I would think you'd get an error. Where is the DBE declared?

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Re: Why i cannot get the correct value of a checkbox inside a void function?
SystemAdmin - Thu May 07 09:13:24 EDT 2009

dpechacek - Thu May 07 08:32:09 EDT 2009
So to be clear it doesn't work in a void function inside a void function but it does work in another void function outside and above the first in the code?

If the DBE was out of scope I would think you'd get an error. Where is the DBE declared?

AAI Services, Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Hi David, yes, you got right the question. As i said, DBE is declared global so i dont think there is a problem of scope. However i should underline that i receive no error messages, program is executed as usual, the only point i dont get the checkbox's correct value.

Re: Why i cannot get the correct value of a checkbox inside a void function?
SystemAdmin - Thu May 07 10:26:23 EDT 2009

SystemAdmin - Thu May 07 09:13:24 EDT 2009
Hi David, yes, you got right the question. As i said, DBE is declared global so i dont think there is a problem of scope. However i should underline that i receive no error messages, program is executed as usual, the only point i dont get the checkbox's correct value.

Actually i solved that problem so its ok however there is another problem i cant solve for the time being which is i cannot prevent the dialog box from popping up. Actually what i try to to do is to loop in a database and whenever i find a view responsive to a certain attribut i display it to the user. If the user checks that he wants it to be set as default view, i should not ask him again which view he wants to will; but in my case my code knows that the user chose a view as a default view but as it is placed in a loop, when the program runs another module, it displays the same dialog box one more time, which is not desired. I should find a way such that once the user checks "default view" option, i should keep this value, i mean the one that i get via "get" function until the end of whole loop. I do not if there is an easy way to do it, without taking off all these functions from the loop?

Re: Why i cannot get the correct value of a checkbox inside a void function?
llandale - Thu May 07 10:37:16 EDT 2009

Not sure exactly what you are saying, but the following might apply:

[1] When function B() is nested inside function A(), B() cannot use variables declared in A(), you get some sort of 'Non local variable access' error. Basically, a function can use its own variables, or those declared in the Main. This makes nested functions pretty hopeless, except when you want to use the same name for different purposes.

2] When you use a string array[ to populate some DBEs ('choice' IIRC), it doesn't actually use the values of that array, it uses the address. The DBE is actually populated when the 'show' or 'realize' commands are issued. Thus, if your array is no longer in context (its garbage on the stack), and the values therein may have been changed. Realistically this means that these arrays[] need to be defined globally, or inside the same function that issues the 'realize'.

>Louie

Re: Why i cannot get the correct value of a checkbox inside a void function?
SystemAdmin - Thu May 07 11:19:19 EDT 2009

llandale - Thu May 07 10:37:16 EDT 2009
Not sure exactly what you are saying, but the following might apply:

[1] When function B() is nested inside function A(), B() cannot use variables declared in A(), you get some sort of 'Non local variable access' error. Basically, a function can use its own variables, or those declared in the Main. This makes nested functions pretty hopeless, except when you want to use the same name for different purposes.

2] When you use a string array[ to populate some DBEs ('choice' IIRC), it doesn't actually use the values of that array, it uses the address. The DBE is actually populated when the 'show' or 'realize' commands are issued. Thus, if your array is no longer in context (its garbage on the stack), and the values therein may have been changed. Realistically this means that these arrays[] need to be defined globally, or inside the same function that issues the 'realize'.

>Louie

Actually my problem of not being able to retrieve checkbox value persists. I declared all variables globally, and "get function" works well in a void function, let's say A but it does not work inside another void function B which is nested in a void function C. also i underline one more time that i receive no error messages. Anyways i thank you guys for your responses.

Re: Why i cannot get the correct value of a checkbox inside a void function?
Tony_Goodman - Fri May 08 03:01:56 EDT 2009

SystemAdmin - Thu May 07 11:19:19 EDT 2009
Actually my problem of not being able to retrieve checkbox value persists. I declared all variables globally, and "get function" works well in a void function, let's say A but it does not work inside another void function B which is nested in a void function C. also i underline one more time that i receive no error messages. Anyways i thank you guys for your responses.

Do not nest functions.

The scope rules for nested functions do not work as you might expect, i.e. the way they work in Pascal for example.